package com.weipai.springboot.module.mapper;

import com.weipai.springboot.model.SaleReturn;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

public interface SaleReturnMapper {
    int deleteByPrimaryKey(String saleReturnId);

    int insert(SaleReturn record);

    int insertSelective(SaleReturn record);

    SaleReturn selectByPrimaryKey(String saleReturnId);

    int updateByPrimaryKeySelective(SaleReturn record);

    int updateByPrimaryKey(SaleReturn record);

    //审核退货订单
    int auditReturnOrder(@Param("auditUserId") String auditUserId, @Param("saleReturnNumber") String saleReturnNumber, @Param("isAudit") Integer isAudit);

    //更改退货订单的状态
    @Update("update c_sale_return set sale_return_status=#{status}, receiving_user_id=#{userId} where sale_return_number=#{saleReturnNumber}")
    int updateSaleReturnStatus(@Param("userId") String userId,
                               @Param("saleReturnNumber") String saleReturnNumber, 
                               @Param("status") int status);

    //某一时间段的退款金额
    Integer getSaleReturnRealPay(@Param("time") String time);
    
    Integer getSaleReturnRealPayByShopId(String shopId);

    //查询用户的退货金额和退货金额
    Map<String,Object> getSaleReturnAmountByCustomerId(String customerId);

    //查询退货订单
    List<Map<String,Object>> getSaleReturnList(@Param("isAudit") Integer isAudit,
                                               @Param("start") Integer start, 
                                               @Param("end") Integer size,
                                               @Param("search") String search, 
                                                @Param("shopId") String shopId,
                                               @Param("startTime") String startTime,
                                               @Param("endTime") String endTime);

    //验证唯一
    List<SaleReturn> verSole(@Param("orderNumber")String orderNumber, @Param("goodsId")String goodsId);

    //查询退货订单数量
    int getSaleReturnAmount(@Param("isAudit") Integer isAudit, 
                            @Param("search") String search,
                            @Param("shopId") String shopId,
                            @Param("startTime") String startTime,
                            @Param("endTime") String endTime);

    //根据退货单号查询退货订单
    SaleReturn getSaleReturnBySaleReturnNumber(String saleReturnNumber);

    //财务 审核
    List<Map<String,Object>> getSaleReturnList22(@Param("isAudit") Integer isAudit,
                                                 @Param("saleReturnStatus") Integer saleReturnStatus,
                                                 @Param("start") Integer start,
                                                 @Param("end") Integer size,
                                                 @Param("search") String search,
                                                 @Param("shopId") String shopId,
                                                 @Param("startTime") String startTime,
                                                 @Param("endTime") String endTime);
    int getSaleReturnAmount22(@Param("isAudit") Integer isAudit,
                              @Param("saleReturnStatus") Integer saleReturnStatus,
                              @Param("search") String search,
                              @Param("shopId") String shopId,
                              @Param("startTime") String startTime,
                              @Param("endTime") String endTime);

    //查看此订单是否是信誉值支付的退货订单
    Map<String,Object> getSaleReturnBySaleReturnNumberAadPayment(@Param("saleReturnNumber") String saleReturnNumber,
                                                                 @Param("modeOfPayment") Integer modeOfPayment);

    List<SaleReturn> getSaleReturnByOrderNumber(String orderNumber);
}